/*
 * @lc app=leetcode.cn id=1544 lang=javascript
 *
 * [1544] 整理字符串
 */

// @lc code=start
/**
 * @param {string} s
 * @return {string}
 */
var makeGood = function (s) {
  let sign;
  s = s.split('');
  do {
    sign = false
    for (let i = 0; i < s.length - 1; i++) {
      if (Math.abs(s[i].charCodeAt() - s[i + 1].charCodeAt()) === 32) {
        sign = true;
        s[i] = s[i + 1] = '';
        i++;
      }
    }
    s = s.filter(ch => ch);
  } while (sign);
  return s.join('');
};
// @lc code=end

